{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "((1, 'fuwen1', 2), (2, '李四', 5), (3, '王五', 4), (4, None, 1), (6, 'hj', 56), (7, 'hhj', 56), (8, 'ghjg', 89), (9, '惊天营救', 7), (10, '绅士们', 8), (11, '悲惨世界', 8), (12, '温蒂妮', 8), (13, '从不，很少，有时，总是', 8), (14, '列夫·朗道：娜塔莎', 6), (15, '饥饿站台', 8), (16, '标准之外', 8), (17, '燃烧女子的肖像', 9), (18, '1/2的魔法', 8), (19, '惊天营救', 7), (20, '绅士们', 8), (21, '悲惨世界', 8), (22, '温蒂妮', 8), (23, '从不，很少，有时，总是', 8), (24, '列夫·朗道：娜塔莎', 6), (25, '饥饿站台', 8), (26, '标准之外', 8), (27, '燃烧女子的肖像', 9), (28, '1/2的魔法', 8), (29, '惊天营救', 7), (30, '绅士们', 8), (31, '悲惨世界', 8), (32, '温蒂妮', 8), (33, '从不，很少，有时，总是', 8), (34, '列夫·朗道：娜塔莎', 6), (35, '饥饿站台', 8), (36, '标准之外', 8), (37, '燃烧女子的肖像', 9), (38, '1/2的魔法', 8))\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "\n",
    "class Connectsql():\n",
    "    def __init__(self):\n",
    "        self.conn=pymysql.connect(host='127.0.0.1',user='root',password='1234',database='myschool',charset='gbk')\n",
    "    def getconn(self):\n",
    "        return self.conn\n",
    "    def getcursor(self):\n",
    "        return self.conn.cursor()\n",
    "    def getclose(self):\n",
    "        self.getconn().close()\n",
    "        self.getcursor().close()\n",
    "sql='select * from student'\n",
    "\n",
    "co=Connectsql()\n",
    "conn=co.getconn()\n",
    "cursor=co.getcursor()\n",
    "res=cursor.execute(sql)\n",
    "print(cursor.fetchall())\n",
    "co.getclose()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
